//
//  XGAddCaseVC.m
//  kuaiyi
//
//  Created by 蒋小哥 on 16/7/6.
//  Copyright © 2016年 Alphts. All rights reserved.
//
/**
 *  病例选择VC
 */
#import "XGAddCaseVC.h"
#import "XGIllnessVC.h"

@interface XGAddCaseVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong)UITableView * tableView;

@property (nonatomic, strong)NSArray * caseListArray;

@end

@implementation XGAddCaseVC

- (void)viewDidLoad {
    [super viewDidLoad];
   
    [self.view addSubview:self.tableView];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];

}

#pragma mark
#pragma mark - 代理方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    if (self.isCell1) {
        return 5;
    }
    return 12;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    
    if (self.isCell1 == YES) {
        cell.textLabel.text = self.caseListArray[indexPath.row];
    }else if (self.isCell1 == NO){
        cell.textLabel.text = [NSString stringWithFormat:@"第%ld行",indexPath.row];
    }
   return cell;
}

//选中cell的事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    //取出选中的cell
   UITableViewCell * selectedCell = [tableView cellForRowAtIndexPath:indexPath];
  
    NSString * str = selectedCell.textLabel.text;
    
    if (self.delegate) {
        [self.delegate reloadCellsWithDetailString:str andIscell1:self.isCell1];
    }
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

#pragma mark
#pragma mark - 懒加载
- (NSArray *)caseListArray {
    if (nil == _caseListArray) {
        _caseListArray = @[@"肿瘤科",@"心血管科",@"血液科",@"神经科",@"骨科"];
    }
    return _caseListArray;
}

- (UITableView *)tableView {
    if (nil == _tableView) {
        _tableView = [[UITableView alloc]initWithFrame:self.view.frame];
    }
    return _tableView;
}

@end












